// components/water-mark-tool/water-mark.js
const myBehavior = require("../../behaviors/requests")
Component({
  /**
   * 组件的属性列表
   */
  behaviors: [myBehavior],
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    userInfo: {
      user_name: "",
      department: "",
      flag: false
    },
  },

  lifetimes: {
    attached: function () {
      let now_day = this.gainDate()
      this.setData({
        now_day:now_day
      })
      let name = wx.getStorageSync('name');
      let company = wx.getStorageSync('company');
      let department = wx.getStorageSync('department');
      if (company == "物流人员") {
        this.getDatas()
      } else {
        if (department.length > 10) {
          this.setData({
            flag: true
          })
        }
        let key1 = "userInfo.user_name"
        let key2 = "userInfo.department"
        this.setData({
          [key1]: name,
          [key2]: department

        })
      }

    },

  },
  /**
   * 组件的方法列表
   */
  methods: {
    getDatas() {
      let url = "https://logisticsengineering.gree.com/package_integrated_api/people_auth_manage/get_direct_companies";
      let data = {

      }
      this.post(url, data).then(res => {

        if (res.code == 20000) {
          let name = wx.getStorageSync('name');
          let key1 = "userInfo.user_name"
          let key2 = "userInfo.department"
          if (res.data[0].length > 10) {
            this.setData({
              flag: true
            })
          }
          this.setData({
            [key1]: name,
            [key2]: res.data[0],

          })


        }
      }).catch(err => {
        console.log(err.mas);
      })
    },

  }
})
